package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.entity.TbGroup;
import com.qf.service.TbGroupService;
import com.qf.mapper.TbGroupMapper;
import com.qf.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class TbGroupServiceImpl extends ServiceImpl<TbGroupMapper, TbGroup>
    implements TbGroupService{

    private final TbGroupMapper tbGroupMapper;

    public TbGroupServiceImpl(TbGroupMapper tbGroupMapper) {
        this.tbGroupMapper = tbGroupMapper;
    }

    @Override
    public Result selectSnum(String snum,Long pageNum ,Long pageSize) {
        TbGroup tbGroup = this.tbGroupMapper.selectSnum(snum,pageNum,pageSize);
        return Result.success("查询成功",tbGroup);
    }

    @Override
    public Result deleteGroupByGid(Long snum) {
        LambdaQueryWrapper<TbGroup> lqw=new LambdaQueryWrapper<>();
        lqw.eq(TbGroup::getStudentId,snum);
        this.tbGroupMapper.delete(lqw);
        return Result.success("删除成功");
    }

    @Override
    public Result updateReplyGroupInfo(Long sid) {

        LambdaQueryWrapper<TbGroup> lqw=new LambdaQueryWrapper<>();
        lqw.eq(TbGroup::getStudentId,sid);
        TbGroup tbGroup = tbGroupMapper.selectOne(lqw);
        return Result.success("查询成功",tbGroup);
    }
}




